package cn.beforedark.yygh.hosp.controller.user;


import cn.beforedark.yygh.common.result.R;
import cn.beforedark.yygh.hosp.service.ScheduleService;
import cn.beforedark.yygh.model.hosp.Schedule;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * /user/hosp/schedule
 */
@RestController
@RequestMapping("/user/hosp/schedule")
public class UserScheduleController {

    @Autowired
    private ScheduleService scheduleService;

    /**
     * 排班信息
     *
     * @param pageNum  pageNum
     * @param pageSize pageSize
     * @param hoscode  hoscode
     * @param depcode  depcode
     * @return vo
     */
    @GetMapping("/page/{pageNum}/{pageSize}/{hoscode}/{depcode}")
    public R getSchedulePage(@PathVariable("pageNum") Long pageNum,
                             @PathVariable("pageSize") Long pageSize,
                             @PathVariable("hoscode") String hoscode,
                             @PathVariable("depcode") String depcode) {
        Map<String, Object> schedules = scheduleService.getSchedulePage(pageNum, pageSize, hoscode, depcode);

        return R.ok().data(schedules);
    }

    /**
     * 排班详细信息
     *
     * @param hoscode  hoscode
     * @param depcode  depcode
     * @param workdate workdate
     * @return vo
     */
    @GetMapping("/detail/{hoscode}/{depcode}/{workdate}")
    public R detail(@PathVariable("hoscode") String hoscode,
                    @PathVariable("depcode") String depcode,
                    @PathVariable("workdate") String workdate) {
        if (null == workdate || workdate.isEmpty() || "null".equals(workdate)) {
            return R.ok().data("list", null);
        }
        List<Schedule> list = scheduleService.detail(hoscode, depcode, workdate);
        return R.ok().data("list", list);
    }

    // @GetMapping("/info/{scheduleId}")
    // public R getScheduleInfo(@PathVariable String scheduleId){
    //     Schedule schedule =  scheduleService.getScheduleInfo(scheduleId);
    //     return R.ok().data("schedule",schedule);
    // }
    //
    // @GetMapping("/{scheduleId}")
    // public ScheduleOrderVo getScheduleById(@PathVariable(value = "scheduleId") String scheduleId){
    //     return scheduleService.getScheduleById(scheduleId);
    // }
}
